#include "hw2_syscalls.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sched.h>

int main(){
	int i=getpid();
	int m=0,k=0,l=0,f;
	int a=1;
	printf("ID is %d\n",i);
	struct sched_param param;
	param.sched_priority=0;
	param.trial_num=5;
	int x=sched_setscheduler(i,SCHED_BRR,&param);
	f=is_brr(i);
	
	printf("1 sched_setscheduler: %d \n",x);
	printf("1 is_brr: %d \n",f);
	f = is_brr(i);
	printf("1 2nd is_brr: %d \n",f);
	
	scanf("%d",&a);
	
	f = is_brr(i);
	printf("2 is_brr (after scanf return): %d \n",f);
	
	int M = 50000;
	
	for(k=0;k<M;k++){
		for(m=0;m<M;m++){
			a = 7 * a + 13;
		}
	}	

	printf("3 finished loop \n");
	f = is_brr(i);
	printf("3 is_brr: %d \n",f);

	printf("4, ready for a scanf on BRR_OD\n");
	scanf("%d",&a);
	printf("4, completed, is_brr: %d\n",is_brr(i));
	return 1;
}
